package com.czjtxy.extraTerm.controller.usermodule;

import com.czjtxy.extraTerm.entity.DO.Tuser;
import com.czjtxy.extraTerm.server.UserService;
import com.czjtxy.extraTerm.serverImpl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * @program: staff-house
 * @author: MingYi
 * @create: 2021/07/01 08:49
 */
@WebServlet(name = "UserServlet", value = "/UserServlet")
public class UserServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserService userService = new UserServiceImpl();
        List<Tuser> tusers = null;
        try {
//            获取数据
            tusers = userService.getAll();
//            设置所获取数据的属性值
            req.setAttribute("tusers", tusers);
        } catch (SQLException | ClassNotFoundException throwables) {
            throwables.printStackTrace();
        }
//        页面跳转
        req.getRequestDispatcher("user/user.jsp").forward(req, resp);
    }
}
